package com.lyloou.practice.utils;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Arrays;

public class DynamicProxyAnnotationUtil {

    public static boolean findAnnotationFromProxy(Class<?> cusAnnotation, Object target, Method method) throws NoSuchMethodException {
        Annotation[] annotations = target.getClass().getMethod(method.getName(), method.getParameterTypes()).getAnnotations();
        return Arrays.stream(annotations).anyMatch(annotation -> annotation.annotationType()
                .isAssignableFrom(cusAnnotation));
    }
}

